﻿using FR.SAFTAnalyser.Services;
using System;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace FR.SAFTAnalyser.Model
{
    public partial class BaseData
    {
        string pk;
        /// <summary>
        /// Primary key of the registry
        /// </summary>
        [System.Xml.Serialization.XmlIgnore]
        public string Pk
        {
            get
            {
                if (string.IsNullOrEmpty(pk))
                    pk = Guid.NewGuid().ToString();
                return pk;
            }
            private set { pk = value; }
        }
    }

    public partial class SourceDocumentsSalesInvoicesInvoice : BaseData, IDataErrorInfo
    {
        public string HashTest { get; set; }

        SourceDocumentsToolTipService tooltip;
        public SourceDocumentsToolTipService Tooltip
        {
            get
            {
                if (tooltip == null)
                    tooltip = new SourceDocumentsToolTipService();
                return tooltip;
            }
            set { tooltip = value; }
        }

        public string Error
        {
            get
            {
                StringBuilder error = new StringBuilder();

                // iterate over all of the properties
                // of this object - aggregating any validation errors
                PropertyDescriptorCollection props = TypeDescriptor.GetProperties(this);
                foreach (PropertyDescriptor prop in props)
                {
                    String propertyError = this[prop.Name];
                    if (propertyError != string.Empty)
                        error.Append((error.Length != 0 ? ", " : "") + propertyError);
                }

                return error.Length == 0 ? null : error.ToString();
            }
        }

        public string this[string columnName]
        {
            get
            {
                Error erro = null;
                if (columnName == "InvoiceNo")
                {
                    erro = ValidateInvoiceNo(appendError: true);
                }
                else if (columnName == "Hash")
                {
                    erro = ValidateHash(appendError: true);
                }
                else if (columnName == "HashControl")
                {
                    erro = ValidateHashControl(appendError: true);
                }
                else if (columnName == "Period")
                {
                    erro = ValidatePeriod(appendError: true);
                }
                else if (columnName == "InvoiceDate")
                {
                    erro = ValidateInvoiceDate(appendError: true);
                }
                else if (columnName == "SelfBillingIndicator")
                {
                    erro = ValidateSelfBillingIndicator(appendError: true);
                }
                else if (columnName == "SystemEntryDate")
                {
                    erro = ValidateSystemEntryDate(appendError: true);
                }
                else if (columnName == "TransactionID")
                {
                    erro = ValidateTransactionID(appendError: true);
                }
                else if (columnName == "CustomerID")
                {
                    erro = ValidateCustomerID(appendError: true);
                }

                return erro == null ? erro.Description : null;
            }
        }

        #region Validation
        public Error ValidateInvoiceNo(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.InvoiceNo) || this.InvoiceNo.Length > 60)
            {
                erro = new Error { Description = "Identificação única com tamanho incorrecto.", Field = "InvoiceNo", TypeofError = this.GetType(), Value = this.InvoiceNo, UID = this.Pk };
                if (appendError)
                    this.Tooltip.InvoiceNo = this.Tooltip.InvoiceNo.FormatTooltipWithError(erro.Description);
            }
            else if (!Regex.IsMatch(this.InvoiceNo, "([a-zA-Z0-9./_-])+ ([a-zA-Z0-9]*/[0-9]+)"))
            {
                erro = new Error { Description = "Identificação única com caracteres não permitidos.", Field = "InvoiceNo", TypeofError = this.GetType(), Value = this.InvoiceNo, UID = this.Pk };
                if (appendError)
                    this.Tooltip.InvoiceNo = this.Tooltip.InvoiceNo.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateHash(bool appendError = false)
        {
            Error erro = null;

            if (string.IsNullOrEmpty(this.Hash) || this.Hash.Length != 172)
            {
                erro = new Error { Description = string.Format("Assinatura do documento {0} de tamanho incorrecto.", this.InvoiceNo), Field = "Hash", TypeofError = this.GetType(), Value = this.Hash, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Hash = this.Tooltip.Hash.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateHashControl(bool appendError = false)
        {
            Error erro = null;

            if (string.IsNullOrEmpty(this.HashControl) || this.HashControl.Length > 40)
            {
                erro = new Error { Description = string.Format("Versão da chave privada utilizada na assinatura do documento {0} incorrecta.", this.InvoiceNo), Field = "HashControl", TypeofError = this.GetType(), Value = this.HashControl, UID = this.Pk };
                if (appendError)
                    this.Tooltip.HashControl = this.Tooltip.HashControl.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidatePeriod(bool appendError = false)
        {
            Error erro = null;

            int periodo = -1;
            Int32.TryParse(this.Period, out periodo);

            if (string.IsNullOrEmpty(this.Period) || periodo < 1 || periodo > 12)
            {
                erro = new Error { Description = string.Format("Mês do período de tributação do documento {0} incorrecto.", this.InvoiceNo), Field = "Period", TypeofError = this.GetType(), Value = this.Period, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Period = this.Tooltip.Period.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateInvoiceDate(bool appendError = false)
        {
            Error erro = null;

            if (this.InvoiceDate < Properties.Settings.Default.MinDate || this.InvoiceDate > DateTime.Now)
            {
                erro = new Error { Description = string.Format("Data de emissão do documento {0} incorrecta.", this.InvoiceNo), Field = "InvoiceDate", TypeofError = this.GetType(), Value = this.InvoiceDate.ToString(), UID = this.Pk };
                if (appendError)
                    this.Tooltip.InvoiceDate = this.Tooltip.InvoiceDate.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateSelfBillingIndicator(bool appendError = false)
        {
            Error erro = null;

            int auto = -1;
            Int32.TryParse(this.SelfBillingIndicator, out auto);
            if (string.IsNullOrEmpty(this.SelfBillingIndicator) || (auto != 0 && auto != 1))
            {
                erro = new Error { Description = string.Format("Indicador de autofaturação do documento {0} incorrecto.", this.InvoiceNo), Field = "SelfBillingIndicator", TypeofError = this.GetType(), Value = this.SelfBillingIndicator, UID = this.Pk };
                if (appendError)
                    this.Tooltip.SelfBillingIndicator = this.Tooltip.SelfBillingIndicator.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateSystemEntryDate(bool appendError = false)
        {
            Error erro = null;

            if (this.SystemEntryDate < Properties.Settings.Default.MinDate || this.SystemEntryDate > DateTime.Now)
            {
                erro = new Error { Description = string.Format("Data da gravação do documento {0} incorrecta.", this.InvoiceNo), Field = "SystemEntryDate", TypeofError = this.GetType(), Value = this.SystemEntryDate.ToString(), UID = this.Pk };
                if (appendError)
                    this.Tooltip.SystemEntryDate = this.Tooltip.SystemEntryDate.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateTransactionID(bool appendError = false)
        {
            Error erro = null;

            if (!string.IsNullOrEmpty(this.TransactionID) && this.TransactionID.Length > 70)
            {
                erro = new Error { Description = string.Format("Identificador da transacção do documento {0} incorrecto.", this.InvoiceNo), Field = "TransactionID", TypeofError = this.GetType(), Value = this.TransactionID, UID = this.Pk };
                if (appendError)
                    this.Tooltip.TransactionID = this.Tooltip.TransactionID.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateCustomerID(bool appendError = false)
        {
            Error erro = null;

            if (string.IsNullOrEmpty(this.CustomerID) || this.CustomerID.Length > 30)
            {
                erro = new Error { Description = string.Format("Chave única da tabela de clientes no documento {0} incorrecta.", this.InvoiceNo), Field = "CustomerID", TypeofError = this.GetType(), Value = this.CustomerID, UID = this.Pk };
                if (appendError)
                    this.Tooltip.CustomerID = this.Tooltip.CustomerID.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        #endregion
    }

    public partial class SourceDocumentsSalesInvoicesInvoiceLine : BaseData, IDataErrorInfo
    {
        /// <summary>
        /// Link to the invoice
        /// </summary>
        public string InvoiceNo { get; set; }

        SourceDocumentsSalesInvoicesInvoiceLineToolTipService tooltip;
        public SourceDocumentsSalesInvoicesInvoiceLineToolTipService Tooltip
        {
            get
            {
                if (tooltip == null)
                    tooltip = new SourceDocumentsSalesInvoicesInvoiceLineToolTipService();
                return tooltip;
            }
            set { tooltip = value; }
        }

        public string Error
        {
            get { throw new NotImplementedException(); }
        }

        [System.Runtime.CompilerServices.IndexerName("Items")]
        public string this[string columnName]
        {
            get
            {
                Error erro = null;
                if (columnName == "LineNumber")
                {
                    erro = ValidateLineNumber(appendError: true);
                }
                else if (columnName == "ProductCode")
                {
                    erro = ValidateProductCode(appendError: true);
                }
                else if (columnName == "ProductDescription")
                {
                    erro = ValidateProductDescription(appendError: true);
                }
                else if (columnName == "Quantity")
                {
                    erro = ValidateQuantity(appendError: true);
                }
                else if (columnName == "UnitOfMeasure")
                {
                    erro = ValidateUnitOfMeasure(appendError: true);
                }
                else if (columnName == "UnitPrice")
                {
                    erro = ValidateUnitPrice(appendError: true);
                }
                else if (columnName == "TaxPointDate")
                {
                    erro = ValidateTaxPointDate(appendError: true);
                }

                return erro == null ? erro.Description : null;
            }
        }

        #region
        public Error ValidateLineNumber(bool appendError = false, string SupPk = "", string invoiceNo = "")
        {
            Error erro = null;
            int num = -1;
            if (!string.IsNullOrEmpty(this.LineNumber))
                Int32.TryParse(this.LineNumber, out num);

            if (string.IsNullOrEmpty(this.LineNumber) || num == -1)
            {
                if (!string.IsNullOrEmpty(invoiceNo))
                    invoiceNo = string.Format(", documento {0}", invoiceNo);

                erro = new Error { Description = string.Format("Número de linha incorrecto{0}.", invoiceNo), Field = "LineNumber", TypeofError = this.GetType(), Value = this.LineNumber, UID = this.Pk, SupUID = SupPk };
                if (appendError)
                    this.Tooltip.LineNumber = this.Tooltip.LineNumber.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateProductCode(bool appendError = false, string SupPk = "", string invoiceNo = "")
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.ProductCode) || this.ProductCode.Length > 30)
            {
                if (!string.IsNullOrEmpty(invoiceNo))
                    invoiceNo = string.Format(", documento {0} ", invoiceNo);

                erro = new Error { Description = string.Format("Identificador do produto ou serviço incorrecto, {0}linha {1}.", invoiceNo, this.LineNumber), Field = "ProductCode", TypeofError = this.GetType(), Value = this.ProductCode, UID = this.Pk, SupUID = SupPk };
                if (appendError)
                    this.Tooltip.ProductCode = this.Tooltip.ProductCode.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateProductDescription(bool appendError = false, string SupPk = "", string invoiceNo = "")
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.ProductDescription) || this.ProductDescription.Length > 200)
            {
                if (!string.IsNullOrEmpty(invoiceNo))
                    invoiceNo = string.Format(", documento {0} ", invoiceNo);

                erro = new Error { Description = string.Format("Descrição do produto ou serviço incorrecta, {0}linha {1}.", invoiceNo, this.LineNumber), Field = "ProductDescription", TypeofError = this.GetType(), Value = this.ProductDescription, UID = this.Pk, SupUID = SupPk };
                if (appendError)
                    this.Tooltip.ProductDescription = this.Tooltip.ProductDescription.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateQuantity(bool appendError = false, string SupPk = "", string invoiceNo = "")
        {
            Error erro = null;
            if (this.Quantity <= 0)
            {
                if (!string.IsNullOrEmpty(invoiceNo))
                    invoiceNo = string.Format(", documento {0} ", invoiceNo);

                erro = new Error { Description = string.Format("Quantidade incorrecta, {0}linha {1}.", invoiceNo, this.LineNumber), Field = "Quantity", TypeofError = this.GetType(), Value = this.Quantity.ToString(), UID = this.Pk, SupUID = SupPk };
                if (appendError)
                    this.Tooltip.Quantity = this.Tooltip.Quantity.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateUnitOfMeasure(bool appendError = false, string SupPk = "", string invoiceNo = "")
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.UnitOfMeasure) || this.UnitOfMeasure.Length > 20)
            {
                if (!string.IsNullOrEmpty(invoiceNo))
                    invoiceNo = string.Format(", documento {0} ", invoiceNo);

                erro = new Error { Description = string.Format("Unidade de medida incorrecta, {0}linha {1}.", invoiceNo, this.LineNumber), Field = "UnitOfMeasure", TypeofError = this.GetType(), Value = this.UnitOfMeasure, UID = this.Pk, SupUID = SupPk };
                if (appendError)
                    this.Tooltip.UnitOfMeasure = this.Tooltip.UnitOfMeasure.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateUnitPrice(bool appendError = false, string SupPk = "", string invoiceNo = "")
        {
            Error erro = null;
            if (this.UnitPrice == 0)
            {
                if (!string.IsNullOrEmpty(invoiceNo))
                    invoiceNo = string.Format(", documento {0} ", invoiceNo);

                erro = new Error { Description = string.Format("Preço unitário incorrecto, {0}linha {1}.", invoiceNo, this.LineNumber), Field = "UnitPrice", TypeofError = this.GetType(), Value = this.UnitPrice.ToString(), UID = this.Pk, SupUID = SupPk };
                if (appendError)
                    this.Tooltip.UnitPrice = this.Tooltip.UnitPrice.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateTaxPointDate(bool appendError = false, string SupPk = "", string invoiceNo = "")
        {
            Error erro = null;
            if (this.TaxPointDate < Properties.Settings.Default.MinDate || this.TaxPointDate > DateTime.Now)
            {
                if (!string.IsNullOrEmpty(invoiceNo))
                    invoiceNo = string.Format(", documento {0} ", invoiceNo);

                erro = new Error { Description = string.Format("Data de envio da mercadoria ou prestação do serviço incorrecta, {0}linha {1}.", invoiceNo, this.LineNumber), Field = "TaxPointDate", TypeofError = this.GetType(), Value = this.TaxPointDate.ToString(), UID = this.Pk, SupUID = SupPk };
                if (appendError)
                    this.Tooltip.TaxPointDate = this.Tooltip.TaxPointDate.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        #endregion
    }

    public partial class Header : BaseData, IDataErrorInfo
    {
        HeaderToolTipService tooltip;
        public HeaderToolTipService Tooltip
        {
            get
            {
                if (tooltip == null)
                    tooltip = new HeaderToolTipService();
                return tooltip;
            }
            set { tooltip = value; }
        }

        public string Error
        {
            get { return null; }
        }

        public string this[string columnName]
        {
            get
            {
                Error erro = null;
                if (columnName == "TaxRegistrationNumber")
                {
                    erro = ValidateTaxRegistrationNumber(appendError: true);
                }
                else if (columnName == "AuditFileVersion")
                {
                    erro = ValidateAuditFileVersion(appendError: true);
                }
                else if (columnName == "BusinessName")
                {
                    erro = ValidateBusinessName(appendError: true);
                }
                else if (columnName == "AddressDetail")
                {
                    erro = ValidateAddressDetail(appendError: true);
                }
                else if (columnName == "BuildingNumber")
                {
                    erro = ValidateBuildingNumber(appendError: true);
                }
                else if (columnName == "City")
                {
                    erro = ValidateCity(appendError: true);
                }
                else if (columnName == "Country")
                {
                    erro = ValidateCountry(appendError: true);
                }
                else if (columnName == "PostalCode")
                {
                    erro = ValidatePostalCode(appendError: true);
                }
                else if (columnName == "Region")
                {
                    erro = ValidateRegion(appendError: true);
                }
                else if (columnName == "StreetName")
                {
                    erro = ValidateStreetName(appendError: true);
                }
                else if (columnName == "CompanyID")
                {
                    erro = ValidateCompanyID(appendError: true);
                }
                else if (columnName == "CompanyName")
                {
                    erro = ValidateCompanyName(appendError: true);
                }
                else if (columnName == "CurrencyCode")
                {
                    erro = ValidateCurrencyCode(appendError: true);
                }
                else if (columnName == "DateCreated")
                {
                    erro = ValidateDateCreated(appendError: true);
                }
                else if (columnName == "Email")
                {
                    erro = ValidateEmail(appendError: true);
                }
                else if (columnName == "EndDate")
                {
                    erro = ValidateEndDate(appendError: true);
                }
                else if (columnName == "Fax")
                {
                    erro = ValidateFax(appendError: true);
                }
                else if (columnName == "FiscalYear")
                {
                    erro = ValidateFiscalYear(appendError: true);
                }
                else if (columnName == "HeaderComment")
                {
                    erro = ValidateHeaderComment(appendError: true);
                }
                else if (columnName == "ProductCompanyTaxID")
                {
                    erro = ValidateProductCompanyTaxID(appendError: true);
                }
                else if (columnName == "ProductID")
                {
                    erro = ValidateProductID(appendError: true);
                }
                else if (columnName == "ProductVersion")
                {
                    erro = ValidateProductVersion(appendError: true);
                }
                else if (columnName == "SoftwareCertificateNumber")
                {
                    erro = ValidateSoftwareCertificateNumber(appendError: true);
                }
                else if (columnName == "StartDate")
                {
                    erro = ValidateStartDate(appendError: true);
                }
                else if (columnName == "TaxAccountingBasis")
                {
                    erro = ValidateTaxAccountingBasis(appendError: true);
                }
                else if (columnName == "TaxEntity")
                {
                    erro = ValidateTaxEntity(appendError: true);
                }
                else if (columnName == "Telephone")
                {
                    erro = ValidateTelephone(appendError: true);
                }
                else if (columnName == "Website")
                {
                    erro = ValidateWebsite(appendError: true);
                }

                if (erro != null)
                    return erro.Description;
                else
                    return null;
            }
        }

        #region Validation
        public Error ValidateTaxRegistrationNumber(bool appendError = false)
        {
            Error erro = null;
            if (!SAFT.Validations.Validations.CheckTaxRegistrationNumber(this.TaxRegistrationNumber))
            {
                erro = new Error { Description = "NIF inválido", Field = "TaxRegistrationNumber", TypeofError = this.GetType(), Value = this.TaxRegistrationNumber, UID = this.Pk };
                if (appendError)
                    this.Tooltip.TaxRegistrationNumber = this.Tooltip.TaxRegistrationNumber.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateAuditFileVersion(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.AuditFileVersion) || this.AuditFileVersion.Length > 10)
            {
                erro = new Error { Description = "Versão do ficheiro SAF-T PT incorrecta.", Field = "AuditFileVersion", TypeofError = this.GetType(), Value = this.AuditFileVersion, UID = this.Pk };
                if (appendError)
                    this.Tooltip.AuditFileVersion = this.Tooltip.AuditFileVersion.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateBusinessName(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.BusinessName) || this.BusinessName.Length > 60)
            {
                erro = new Error { Description = "Designação comercial incorrecta.", Field = "BusinessName", TypeofError = this.GetType(), Value = this.BusinessName, UID = this.Pk };
                if (appendError)
                    this.Tooltip.BusinessName = this.Tooltip.BusinessName.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateAddressDetail(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.CompanyAddress.AddressDetail) || this.CompanyAddress.AddressDetail.Length > 100)
            {
                erro = new Error { Description = "Morada detalhada incorrecta.", Field = "AddressDetail", TypeofError = this.GetType(), Value = this.CompanyAddress.AddressDetail, UID = this.Pk };
                if (appendError)
                    this.Tooltip.AddressDetail = this.Tooltip.AddressDetail.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateBuildingNumber(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.CompanyAddress.BuildingNumber) && this.CompanyAddress.BuildingNumber.Length > 10)
            {
                erro = new Error { Description = "Número polícia incorrecto.", Field = "BuildingNumber", TypeofError = this.GetType(), Value = this.CompanyAddress.BuildingNumber, UID = this.Pk };
                if (appendError)
                    this.Tooltip.BuildingNumber = this.Tooltip.BuildingNumber.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateCity(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.CompanyAddress.City) || this.CompanyAddress.City.Length > 50)
            {
                erro = new Error { Description = "Localidade incorrecta.", Field = "City", TypeofError = this.GetType(), Value = this.CompanyAddress.City, UID = this.Pk };
                if (appendError)
                    this.Tooltip.City = this.Tooltip.City.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateCountry(bool appendError = false)
        {
            string country = null;
            if (this.CompanyAddress != null || this.CompanyAddress.Country != null)
            {
                if (this.CompanyAddress.Country is System.Xml.XmlNode[])
                {
                    System.Xml.XmlNode[] nodes = this.CompanyAddress.Country as System.Xml.XmlNode[];
                    if (nodes != null && nodes.Length > 0)
                        country = (this.CompanyAddress.Country as System.Xml.XmlNode[])[0].InnerText;
                }
                else if (this.CompanyAddress.Country != null)
                    country = this.CompanyAddress.Country.ToString();
            }

            Error erro = null;
            if (string.IsNullOrEmpty(country) || country != "PT")
            {
                erro = new Error { Description = "Localidade incorrecta.", Field = "City", TypeofError = this.GetType(), Value = country, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Country = this.Tooltip.Country.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidatePostalCode(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.CompanyAddress.PostalCode) || this.CompanyAddress.PostalCode.Length > 50)
            {
                erro = new Error { Description = "Código postal incorrecto.", Field = "PostalCode", TypeofError = this.GetType(), Value = this.CompanyAddress.PostalCode, UID = this.Pk };
                if (appendError)
                    this.Tooltip.PostalCode = this.Tooltip.PostalCode.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateRegion(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.CompanyAddress.Region) && this.CompanyAddress.Region.Length > 50)
            {
                erro = new Error { Description = "Distrito incorrecto.", Field = "Region", TypeofError = this.GetType(), Value = this.CompanyAddress.Region, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Region = this.Tooltip.Region.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateStreetName(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.CompanyAddress.StreetName) && this.CompanyAddress.StreetName.Length > 90)
            {
                erro = new Error { Description = "Nome da rua incorrecto.", Field = "StreetName", TypeofError = this.GetType(), Value = this.CompanyAddress.StreetName, UID = this.Pk };
                if (appendError)
                    this.Tooltip.StreetName = this.Tooltip.StreetName.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateCompanyID(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.CompanyID) || this.CompanyID.Length > 50 || !Regex.IsMatch(this.CompanyID, "([0-9])+|([a-zA-Z0-9-/]+ [0-9]+)"))
            {
                if (!SAFT.Validations.Validations.CheckTaxRegistrationNumber(this.CompanyID))
                {
                    erro = new Error { Description = "Registo comercial incorrecto.", Field = "CompanyID", TypeofError = this.GetType(), Value = this.CompanyID, UID = this.Pk };
                    if (appendError)
                        this.Tooltip.CompanyID = this.Tooltip.CompanyID.FormatTooltipWithError(erro.Description);
                }
            }
            return erro;
        }
        public Error ValidateCompanyName(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.CompanyName) || this.CompanyName.Length > 100)
            {
                erro = new Error { Description = "Nome empresa incorrecto.", Field = "CompanyName", TypeofError = this.GetType(), Value = this.CompanyName, UID = this.Pk };
                if (appendError)
                    this.Tooltip.CompanyName = this.Tooltip.CompanyName.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateCurrencyCode(bool appendError = false)
        {
            Error erro = null;
            if (this.CurrencyCode == null || this.CurrencyCode.ToString() != "EUR")
            {
                erro = new Error { Description = "Código moeda incorrecto.", Field = "CurrencyCode", TypeofError = this.GetType(), Value = string.Format("{0}", this.CurrencyCode ?? "null"), UID = this.Pk };
                if (appendError)
                    this.Tooltip.CurrencyCode = this.Tooltip.CurrencyCode.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateDateCreated(bool appendError = false)
        {
            Error erro = null;
            if (this.DateCreated < Properties.Settings.Default.MinDate || this.DateCreated > DateTime.Now)
            {
                erro = new Error { Description = "Data de criação do ficheiro incorrecta.", Field = "DateCreated", TypeofError = this.GetType(), Value = this.DateCreated.ToString(), UID = this.Pk };
                if (appendError)
                    this.Tooltip.DateCreated = this.Tooltip.DateCreated.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateEmail(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.Email) && (this.Email.Length > 60 || !Regex.IsMatch(this.Email, @"\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b")))
            {
                erro = new Error { Description = "Email incorrecto.", Field = "Email", TypeofError = this.GetType(), Value = this.Email, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Email = this.Tooltip.Email.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateEndDate(bool appendError = false)
        {
            Error erro = null;
            if (this.EndDate == DateTime.MinValue)
            {
                erro = new Error { Description = "Data do fim do periodo incorrecta.", Field = "EndDate", TypeofError = this.GetType(), Value = this.EndDate.ToString(), UID = this.Pk };
                if (appendError)
                    this.Tooltip.EndDate = this.Tooltip.EndDate.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateFax(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.Fax) && this.Fax.Length > 20)
            {
                erro = new Error { Description = "Fax incorrecto.", Field = "Fax", TypeofError = this.GetType(), Value = this.Fax, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Fax = this.Tooltip.Fax.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateFiscalYear(bool appendError = false)
        {
            Error erro = null;
            int ano = -1;
            Int32.TryParse(this.FiscalYear, out ano);
            if (string.IsNullOrEmpty(this.FiscalYear) || this.FiscalYear.Length > 4 || ano == -1)
            {
                erro = new Error { Description = "Ano fiscal incorrecto.", Field = "FiscalYear", TypeofError = this.GetType(), Value = this.FiscalYear, UID = this.Pk };
                if (appendError)
                    this.Tooltip.FiscalYear = this.Tooltip.FiscalYear.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateHeaderComment(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.HeaderComment) && this.HeaderComment.Length > 255)
            {
                erro = new Error { Description = "Comentário demasiado longo.", Field = "HeaderComment", TypeofError = this.GetType(), Value = this.HeaderComment, UID = this.Pk };
                if (appendError)
                    this.Tooltip.HeaderComment = this.Tooltip.HeaderComment.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateProductCompanyTaxID(bool appendError = false)
        {
            Error erro = null;
            if (!SAFT.Validations.Validations.CheckTaxRegistrationNumber(this.ProductCompanyTaxID))
            {
                erro = new Error { Description = "NIF da empresa produtora de saftware inválido.", Field = "ProductCompanyTaxID", TypeofError = this.GetType(), Value = this.ProductCompanyTaxID, UID = this.Pk };
                if (appendError)
                    this.Tooltip.ProductCompanyTaxID = this.Tooltip.ProductCompanyTaxID.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateProductID(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.ProductID) || this.ProductID.Length > 255 || !this.ProductID.Contains('/'))
            {
                erro = new Error { Description = "Nome da aplicação incorrecto.", Field = "ProductID", TypeofError = this.GetType(), Value = this.ProductID, UID = this.Pk };
                if (appendError)
                    this.Tooltip.ProductID = this.Tooltip.ProductID.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateProductVersion(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.ProductVersion) || this.ProductVersion.Length > 30)
            {
                erro = new Error { Description = "Versão da aplicação incorrecta.", Field = "ProductVersion", TypeofError = this.GetType(), Value = this.ProductVersion, UID = this.Pk };
                if (appendError)
                    this.Tooltip.ProductVersion = this.Tooltip.ProductVersion.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateSoftwareCertificateNumber(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.SoftwareCertificateNumber) || this.SoftwareCertificateNumber.Length > 20)
            {
                erro = new Error { Description = "Número de certificação incorrecto.", Field = "SoftwareCertificateNumber", TypeofError = this.GetType(), Value = this.SoftwareCertificateNumber, UID = this.Pk };
                if (appendError)
                    this.Tooltip.SoftwareCertificateNumber = this.Tooltip.SoftwareCertificateNumber.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateStartDate(bool appendError = false)
        {
            Error erro = null;
            if (this.StartDate < Properties.Settings.Default.MinDate)
            {
                erro = new Error { Description = "Data do início do periodo incorrecta.", Field = "StartDate", TypeofError = this.GetType(), Value = this.StartDate.ToString(), UID = this.Pk };
                if (appendError)
                    this.Tooltip.StartDate = this.Tooltip.StartDate.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateTaxAccountingBasis(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.TaxAccountingBasis.ToString()) || this.TaxAccountingBasis.ToString().Length > 1)
            {
                erro = new Error { Description = "Sistema contabilístico incorrecto.", Field = "TaxAccountingBasis", TypeofError = this.GetType(), Value = this.TaxAccountingBasis.ToString(), UID = this.Pk };
                if (appendError)
                    this.Tooltip.TaxAccountingBasis = this.Tooltip.TaxAccountingBasis.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateTaxEntity(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.TaxEntity) || this.TaxEntity.Length > 20)
            {
                erro = new Error { Description = "Identificação do estabelecimento incorrecta.", Field = "TaxEntity", TypeofError = this.GetType(), Value = this.TaxEntity, UID = this.Pk };
                if (appendError)
                    this.Tooltip.TaxEntity = this.Tooltip.TaxEntity.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateTelephone(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.Telephone) && this.Telephone.Length > 20)
            {
                erro = new Error { Description = "Identificação do estabelecimento incorrecta.", Field = "Telephone", TypeofError = this.GetType(), Value = this.Telephone, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Telephone = this.Tooltip.Telephone.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        public Error ValidateWebsite(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.Website) && this.Website.Length > 60)
            {
                erro = new Error { Description = "Website incorrecto.", Field = "Website", TypeofError = this.GetType(), Value = this.Website, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Website = this.Tooltip.Website.FormatTooltipWithError(erro.Description);
            }
            return erro;
        }
        #endregion Validation
    }

    public partial class Product : BaseData, IDataErrorInfo
    {
        ProductToolTipService tooltip;
        public ProductToolTipService Tooltip
        {
            get
            {
                if (tooltip == null)
                    tooltip = new ProductToolTipService();
                return tooltip;
            }
            set { tooltip = value; }
        }

        public string Error
        {
            get { throw new NotImplementedException(); }
        }

        public string this[string columnName]
        {
            get
            {
                Error erro = null;
                if (columnName == "ProductCode")
                {
                    erro = ValidateProductCode(appendError: true);
                }
                else if (columnName == "ProductGroup")
                {
                    erro = ValidateProductGroup(appendError: true);
                }
                else if (columnName == "ProductDescription")
                {
                    erro = ValidateProductDescription(appendError: true);
                }
                else if (columnName == "ProductNumberCode")
                {
                    erro = ValidateProductNumberCode(appendError: true);
                }

                return erro == null ? "" : erro.Description;
            }
        }

        #region Validation

        public Error ValidateProductCode(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.ProductCode) || this.ProductCode.Length > 30)
            {
                erro = new Error { Description = "Código do produto inválido", Field = "ProductCode", TypeofError = this.GetType(), Value = this.ProductCode, UID = this.Pk };
                if (appendError)
                    this.Tooltip.ProductCode = this.Tooltip.ProductCode.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateProductGroup(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.ProductGroup) && this.ProductCode.Length > 50)
            {
                erro = new Error { Description = "Família do produto ou serviço inválida", Field = "ProductGroup", TypeofError = this.GetType(), Value = this.ProductGroup, UID = this.Pk };
                if (appendError)
                    this.Tooltip.ProductGroup = this.Tooltip.ProductGroup.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateProductDescription(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.ProductDescription) || this.ProductDescription.Length > 200)
            {
                erro = new Error { Description = "Descrição do produto ou serviço inválida", Field = "ProductDescription", TypeofError = this.GetType(), Value = this.ProductDescription, UID = this.Pk };
                if (appendError)
                    this.Tooltip.ProductDescription = this.Tooltip.ProductDescription.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateProductNumberCode(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.ProductNumberCode) || this.ProductNumberCode.Length > 50)
            {
                erro = new Error { Description = "Família do produto ou serviço inválida", Field = "ProductNumberCode", TypeofError = this.GetType(), Value = this.ProductNumberCode, UID = this.Pk };
                if (appendError)
                    this.Tooltip.ProductNumberCode = this.Tooltip.ProductNumberCode.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }

        #endregion Validation
    }

    public partial class Customer : BaseData, IDataErrorInfo
    {
        CustomerToolTipService tooltip;
        public CustomerToolTipService Tooltip
        {
            get
            {
                if (tooltip == null)
                    tooltip = new CustomerToolTipService();
                return tooltip;
            }
            set { tooltip = value; }
        }

        public string Error
        {
            get { throw new NotImplementedException(); }
        }

        public string this[string columnName]
        {
            get
            {
                Error erro = null;
                if (columnName == "CustomerID")
                {
                    erro = ValidateCustomerID(appendError: true);
                }
                else if (columnName == "AccountID")
                {
                    erro = ValidateAccountID(appendError: true);
                }
                else if (columnName == "CustomerTaxID")
                {
                    erro = ValidateCustomerTaxID(appendError: true);
                }
                else if (columnName == "CompanyName")
                {
                    erro = ValidateCompanyName(appendError: true);
                }
                else if (columnName == "Contact")
                {
                    erro = ValidateContact(appendError: true);
                }
                else if (columnName == "Telephone")
                {
                    erro = ValidateTelephone(appendError: true);
                }
                else if (columnName == "Fax")
                {
                    erro = ValidateFax(appendError: true);
                }
                else if (columnName == "Email")
                {
                    erro = ValidateEmail(appendError: true);
                }
                else if (columnName == "Website")
                {
                    erro = ValidateWebsite(appendError: true);
                }
                else if (columnName == "SelfBillingIndicator")
                {
                    erro = ValidateSelfBillingIndicator(appendError: true);
                }

                return erro == null ? "" : erro.Description;
            }
        }

        #region Validation

        public Error ValidateCustomerID(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.CustomerID) || this.CustomerID.Length > 30)
            {
                erro = new Error { Description = "Identificador único do cliente inválido", Field = "CustomerID", TypeofError = this.GetType(), Value = this.CustomerID, UID = this.Pk };
                if (appendError)
                    this.Tooltip.CustomerID = this.Tooltip.CustomerID.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateAccountID(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.AccountID) || this.AccountID.Length > 30)
            {
                erro = new Error { Description = "Código da conta inválido", Field = "AccountID", TypeofError = this.GetType(), Value = this.AccountID, UID = this.Pk };
                if (appendError)
                    this.Tooltip.AccountID = this.Tooltip.AccountID.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateCustomerTaxID(bool appendError = false)
        {
            Error erro = null;
            if (!SAFT.Validations.Validations.CheckTaxRegistrationNumber(this.CustomerTaxID))
            {
                erro = new Error { Description = "Número de identificação fiscal inválido", Field = "CustomerTaxID", TypeofError = this.GetType(), Value = this.CustomerTaxID, UID = this.Pk };
                if (appendError)
                    this.Tooltip.CustomerTaxID = this.Tooltip.CustomerTaxID.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateCompanyName(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.CompanyName) || this.CompanyName.Length > 100)
            {
                erro = new Error { Description = "Nome da empresa inválido", Field = "CompanyName", TypeofError = this.GetType(), Value = this.CompanyName, UID = this.Pk };
                if (appendError)
                    this.Tooltip.CompanyName = this.Tooltip.CompanyName.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateContact(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.Contact) && this.Contact.Length > 50)
            {
                erro = new Error { Description = "Nome do contacto na empresa inválido.", Field = "Contact", TypeofError = this.GetType(), Value = this.Contact, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Contact = this.Tooltip.Contact.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateTelephone(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.Telephone) && this.Telephone.Length > 20)
            {
                erro = new Error { Description = "Telefone inválido", Field = "Telephone", TypeofError = this.GetType(), Value = this.Telephone, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Telephone = this.Tooltip.Telephone.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateFax(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.Fax) && this.Fax.Length > 20)
            {
                erro = new Error { Description = "Fax inválido", Field = "Fax", TypeofError = this.GetType(), Value = this.Fax, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Fax = this.Tooltip.Fax.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateEmail(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.Email) && this.Email.Length > 60)
            {
                erro = new Error { Description = "Email inválido", Field = "Email", TypeofError = this.GetType(), Value = this.Email, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Email = this.Tooltip.Email.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateWebsite(bool appendError = false)
        {
            Error erro = null;
            if (!string.IsNullOrEmpty(this.Website) && this.Website.Length > 60)
            {
                erro = new Error { Description = "Website inválido", Field = "Website", TypeofError = this.GetType(), Value = this.Website, UID = this.Pk };
                if (appendError)
                    this.Tooltip.Website = this.Tooltip.Website.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateSelfBillingIndicator(bool appendError = false)
        {
            Error erro = null;

            int selfBillingIndicator = -1;
            if (!string.IsNullOrEmpty(this.SelfBillingIndicator))
                Int32.TryParse(this.SelfBillingIndicator, out selfBillingIndicator);

            if (string.IsNullOrEmpty(this.SelfBillingIndicator) || selfBillingIndicator == -1)
            {
                erro = new Error { Description = "Nº de conta inválido", Field = "SelfBillingIndicator", TypeofError = this.GetType(), Value = this.SelfBillingIndicator, UID = this.Pk };
                if (appendError)
                    this.Tooltip.SelfBillingIndicator = this.Tooltip.SelfBillingIndicator.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }

        #endregion Validation
    }

    public partial class TaxTableEntry : BaseData, IDataErrorInfo
    {
        TaxToolTipService tooltip;
        public TaxToolTipService Tooltip
        {
            get
            {
                if (tooltip == null)
                    tooltip = new TaxToolTipService();
                return tooltip;
            }
            set { tooltip = value; }
        }

        public string Error
        {
            get { throw new NotImplementedException(); }
        }

        [System.Runtime.CompilerServices.IndexerName("Items")]
        public string this[string columnName]
        {
            get
            {
                Error erro = null;
                if (columnName == "TaxCountryRegion")
                {
                    erro = ValidateTaxCountryRegion(appendError: true);
                }
                else if (columnName == "TaxCode")
                {
                    erro = ValidateTaxCode(appendError: true);
                }

                return erro == null ? "" : erro.Description;
            }
        }

        #region Validations

        public Error ValidateTaxCountryRegion(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.TaxCountryRegion) || this.TaxCountryRegion.Length > 5)
            {
                erro = new Error { Description = "País ou região do imposto inválido", Field = "TaxCountryRegion", TypeofError = this.GetType(), Value = this.TaxCountryRegion, UID = this.Pk };
                if (appendError)
                    this.Tooltip.TaxCountryRegion = this.Tooltip.TaxCountryRegion.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        public Error ValidateTaxCode(bool appendError = false)
        {
            Error erro = null;
            if (string.IsNullOrEmpty(this.TaxCode) || this.TaxCode.Length > 10)
            {
                erro = new Error { Description = "Código do imposto inválido", Field = "TaxCode", TypeofError = this.GetType(), Value = this.TaxCode, UID = this.Pk };
                if (appendError)
                    this.Tooltip.TaxCode = this.Tooltip.TaxCode.FormatTooltipWithError(erro.Description);
            }

            return erro;
        }
        //public Error ValidateDescription(bool appendError = false)
        //{
        //    Error erro = null;
        //    if (string.IsNullOrEmpty(this.Description) || this.Description.Length > 255)
        //    {
        //        erro = new Error { Description = "Identificador único do cliente inválido", Field = "Description", TypeofError = this.GetType(), ID = this.Description, UID = this.Pk };
        //        if (appendError)
        //            this.Tooltip.Description = this.Tooltip.Description.FormatTooltipWithError(erro.Description);
        //    }

        //    return erro;
        //}
        //public Error ValidateTaxExpirationDate(bool appendError = false)
        //{
        //    Error erro = null;
        //    if (string.IsNullOrEmpty(this.TaxExpirationDate) || this.TaxExpirationDate.Length > 30)
        //    {
        //        erro = new Error { Description = "Data de fim de vigência inválida", Field = "TaxExpirationDate", TypeofError = this.GetType(), ID = this.TaxExpirationDate, UID = this.Pk };
        //        if (appendError)
        //            this.Tooltip.TaxExpirationDate = this.Tooltip.TaxExpirationDate.FormatTooltipWithError(erro.Description);
        //    }

        //    return erro;
        //}
        //public Error ValidateTaxPercentage(bool appendError = false)
        //{
        //    Error erro = null;
        //    if (string.IsNullOrEmpty(this.TaxPercentage) || this.TaxPercentage.Length > 30)
        //    {
        //        erro = new Error { Description = "Percentagem da taxa do imposto inválida.", Field = "TaxPercentage", TypeofError = this.GetType(), ID = this.TaxPercentage, UID = this.Pk };
        //        if (appendError)
        //            this.Tooltip.TaxPercentage = this.Tooltip.TaxPercentage.FormatTooltipWithError(erro.Description);
        //    }

        //    return erro;
        //}
        //public Error ValidateTaxAmount(bool appendError = false)
        //{
        //    Error erro = null;
        //    if (string.IsNullOrEmpty(this.TaxAmount) || this.TaxAmount.Length > 30)
        //    {
        //        erro = new Error { Description = "Identificador único do cliente inválido", Field = "TaxAmount", TypeofError = this.GetType(), ID = this.TaxAmount, UID = this.Pk };
        //        if (appendError)
        //            this.Tooltip.TaxAmount = this.Tooltip.TaxAmount.FormatTooltipWithError(erro.Description);
        //    }

        //    return erro;
        //}
        #endregion
    }

    public partial class Supplier : BaseData, IDataErrorInfo
    {
        public string Error
        {
            get { throw new NotImplementedException(); }
        }

        public string this[string columnName]
        {
            get { throw new NotImplementedException(); }
        }
    }

    public partial class GeneralLedger : BaseData, IDataErrorInfo
    {

        public string Error
        {
            get { throw new NotImplementedException(); }
        }

        public string this[string columnName]
        {
            get { throw new NotImplementedException(); }
        }
    }

    public partial class GeneralLedgerEntriesJournal : BaseData, IDataErrorInfo
    {
        public string Error
        {
            get { throw new NotImplementedException(); }
        }

        public string this[string columnName]
        {
            get { throw new NotImplementedException(); }
        }
    }

    public partial class GeneralLedgerEntriesJournalTransaction : BaseData, IDataErrorInfo
    {
        public string Error
        {
            get { throw new NotImplementedException(); }
        }

        [System.Runtime.CompilerServices.IndexerName("Items")]
        public string this[string columnName]
        {
            get { throw new NotImplementedException(); }
        }
    }

    public partial class GeneralLedgerEntriesJournalTransactionLine : BaseData, IDataErrorInfo
    {
        public string Error
        {
            get { throw new NotImplementedException(); }
        }

        [System.Runtime.CompilerServices.IndexerName("Items")]
        public string this[string columnName]
        {
            get { throw new NotImplementedException(); }
        }
    }

    public partial class SchemaResults { }

    public partial class HashResults { }
}
